package com.nowc.week.w103_ak;

import java.io.*;
import java.util.*;

public class e {
    static final int MAXX = (1 << 20); // maximum query value
    static boolean[] exist = new boolean[MAXX + 1];
    static List<Integer>[] tree;
    static int[] weight;

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        int n = Integer.parseInt(st.nextToken());
        int q = Integer.parseInt(st.nextToken());

        // read node weights
        String s = br.readLine().trim();
        weight = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            weight[i] = s.charAt(i - 1) - '0';
        }

        // build tree
        tree = new ArrayList[n + 1];
        for (int i = 1; i <= n; i++) {
            tree[i] = new ArrayList<>();
        }
        for (int i = 0; i < n - 1; i++) {
            st = new StringTokenizer(br.readLine());
            int u = Integer.parseInt(st.nextToken());
            int v = Integer.parseInt(st.nextToken());
            tree[u].add(v);
            tree[v].add(u);
        }

        // DFS from root = 1, compute all ancestor-descendant path values (forward & reverse) up to length 21
        dfs(1, 0, new int[22], new int[22], 0);

        // answer queries
        PrintWriter out = new PrintWriter(System.out);
        while (q-- > 0) {
            int x = Integer.parseInt(br.readLine());
            out.println(exist[x] ? "YES" : "NO");
        }
        out.flush();
    }

    /**
     * @param u current node
     * @param parent parent node
     * @param parentVals forward values of last L bits from ancestor to parent
     * @param parentRevs reverse values of last L bits from parent to ancestor
     * @param depth current depth (root at depth 0)
     */
    static void dfs(int u, int parent, int[] parentVals, int[] parentRevs, int depth) {
        int[] currVals = new int[22];
        int[] currRevs = new int[22];
        int bit = weight[u];
        int maxLen = Math.min(depth + 1, 21);
        for (int L = 1; L <= maxLen; L++) {
            if (L == 1) {
                currVals[1] = bit;
                currRevs[1] = bit;
            } else {
                // forward: shift previous and add current bit
                currVals[L] = ((parentVals[L - 1] << 1) | bit);
                // reverse: take previous reverse and add current at high bit
                currRevs[L] = (parentRevs[L - 1] | (bit << (L - 1)));
            }
            int v1 = currVals[L], v2 = currRevs[L];
            if (v1 <= MAXX) exist[v1] = true;
            if (v2 <= MAXX) exist[v2] = true;
        }
        for (int v : tree[u]) {
            if (v == parent) continue;
            dfs(v, u, currVals, currRevs, depth + 1);
        }
    }
}
